package com.contact;

import java.util.ArrayList;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class MapItemizedOverlay extends ItemizedOverlay<OverlayItem> {
	private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
	private ArrayList<Info> infos = new ArrayList<Info>();
	private Context context;

	public MapItemizedOverlay(Drawable defaultMarker) {
		super(boundCenterBottom(defaultMarker));

	}

	public MapItemizedOverlay(Drawable defaultMarker, Context context) {
		super(boundCenterBottom(defaultMarker));
		this.context = context;
		populate();
	}

	@Override
	protected OverlayItem createItem(int i) {
		return mOverlays.get(i);
	}

	@Override
	public int size() {
		return mOverlays.size();
	}

	public void addOverlay(OverlayItem overlay, Info info) {
		
		mOverlays.add(overlay);
		populate();
		infos.add(info);
	}
	public void removeItem(int index) {
		if (index < size()) {
			mOverlays.remove(index);
			populate();
		}
	}

	public void clear() {
		mOverlays.clear();
		populate();
	}

	@Override
	protected boolean onTap(int index) {
		Info info = infos.get(index);
		
		return true;
	}

}
